package ge.engine;

import ge.modules.events.CollisionModule;
import ge.modules.logics.SquareCollide;
/**
 * 
 * @author Abel
 *	Object camera is who show us what we have to see in the screen.
 *	By default, the camera has the same size that the canvas size
 *	There is only one camera. It doesn't support now adays two separate layers with two differnets cameras.
 */
public class Camera extends Actor implements PositionableArea
{
	protected double x;
	protected double y;
	protected SquareCollide logicCamera;
	public Camera()
	{
		x = y = 0;
		logicCamera = new SquareCollide(Engine.getCanvasWidth(), Engine.getCanvasHeigth(),CollisionModule.CAMERA);
		logicCamera.setPos(0, 0);
		//logicCamera.enableCollide(true); Se hace ya en enableCamera
		add(logicCamera);
		//System.out.println("se ejecuta");
		
	}
	
	public void setPos(double x, double y)
	{
		this.x = x;
		this.y = y;
		logicCamera.setPos(x,y);
	}
	public double getX()
	{
		return x;
	}
	public double getY()
	{
		return y;
	}
	/**
	 * 	Get's the relative position in the canvas
	 * @param x Coordinate x of the object
	 * @return Relative coordinate
	 */
	public double getRelativeX(double x)
	{
		return x-this.x;
	}
	/**
	 * 	Get's the relative position in the canvas
	 * @param y Coordinate y of the object
	 * @return Relative coordinate
	 */
	public double getRelativeY(double y)
	{
		return y-this.y;
	}
	/**
	 * 	Disables the actual camera, it's important, for the collisions test in the canvas.
	 */
	public void disableCamera()
	{
		logicCamera.enableCollide(false);
	}
	/**
	 * 	Enables the camera
	 */
	public void enableCamera()
	{
		logicCamera.enableCollide(true);
	}
	
	/**
	 * 
	 * @return The width of the camera, that it use to be the same that the canvas
	 */
	public double getWidth()
	{
		return Engine.getCanvasWidth();
	}
	
	/**
	 * 
	 * @return The width of the camera, that it use to be the same that the canvas
	 */
	public double getHeight()
	{
		return Engine.getCanvasHeigth();
	}

	@Override
	/**
	 * 	That camera has the area of the canvas.
	 * 	That function won't do anything
	 * 	@deprecated
	 */
	public void setArea(double width, double height)
	{

	}
}
